package com.practice.zookeeper.client;

import java.lang.reflect.Proxy;

import com.practice.zookeeper.client.zk.IServiceDiscovery;

public class RpcClientProxy {
	
	private IServiceDiscovery discovery;
	
	public RpcClientProxy(IServiceDiscovery discovery) {
		this.discovery = discovery;
	}

	@SuppressWarnings("unchecked")
	public <T> T createProxy(final Class<T> service, String version) {
		return (T) Proxy.newProxyInstance(service.getClassLoader(), new Class[] {service}, 
				new RemoteInvocationHandler(discovery, version));
	}

}
